package com.zyq.controller;

import com.zyq.model.common.ResponseBean;
import com.zyq.model.entity.RiskLevel;
import com.zyq.service.IRiskLevelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

/**
 * 风险等级Controller
 *
 * @author zyq
 * @date 2021-12-09
 */
@Api( tags = "风险等级接口")
@RestController
@RequestMapping("/riskLevel")
public class RiskLevelController
{
    @Autowired
    private IRiskLevelService riskLevelService;

    /**
     * 查询风险等级列表
     */
    @ApiOperation("查询风险等级列表")
    @GetMapping("/list")
    public ResponseBean list()
    {
        return new ResponseBean(HttpStatus.OK.value(), "查询成功(Query was successful)", riskLevelService.selectRiskLevelList());
    }


    /**
     * 新增风险等级
     */
    @ApiOperation("新增风险等级")
    @PostMapping
    public ResponseBean add(@RequestBody RiskLevel riskLevel)
    {
        riskLevelService.insertRiskLevel(riskLevel);
        return new ResponseBean(HttpStatus.OK.value(), "操作成功", null);
    }

    /**
     * 修改风险等级
     */
    @ApiOperation("修改风险等级")
    @PutMapping
    public ResponseBean edit(@RequestBody RiskLevel riskLevel)
    {
        riskLevelService.updateRiskLevel(riskLevel);
        return new ResponseBean(HttpStatus.OK.value(), "操作成功", null);
    }

    /**
     * 删除风险等级
     */
    @ApiOperation("删除风险等级")
    @DeleteMapping("/{ids}")
    public ResponseBean remove(@PathVariable Long[] ids)
    {
        riskLevelService.deleteRiskLevelByIds(ids);
        return new ResponseBean(HttpStatus.OK.value(), "操作成功", null);
    }


}
